
<h3 mat-dialog-title class="mb-3">Train your '{{data.type}}' model on {{count}} snippets</h3>

<form (ngSubmit)="save()">
  <div mat-dialog-content>

    <mat-error *ngIf="count === 0" class="mb-2">
      No training data, you need to create or import training data first.
    </mat-error>
    <p class="text-muted">
      Notice, it is highly unlikely that you want to use the train feature. 99.9% of use cases achieve
      better results by using the vectorise function as an alternative.
    </p>

    <div class="row">

      <div class="col-12">

        <mat-form-field class="w-100 standalone-field">
          <span
            matPrefix
            matTooltip="Base model to train from"
            class="d-flex flex-nowrap align-items-center justify-content-between me-2">
            <mat-icon>help_outline</mat-icon>
            <span class="text-muted">|</span>
          </span>
          <mat-select
            [(ngModel)]="model"
            placeholder="Base model"
            name="model">
            <mat-select-trigger>
              {{model?.id}}
            </mat-select-trigger>
            <mat-option
              class="multiline-mat-option"
              *ngFor="let idx of models"
              [value]="idx">
              <span class="d-block name-line" #typeName>
                {{idx.id}}
              </span>
              <span class="d-block description-line">
                Owned by {{idx.owned_by}}
              </span>
            </mat-option>
          </mat-select>
        </mat-form-field>
    
      </div>

    </div>

    <div class="row">

      <div class="col-12 d-flex justify-content-md-between align-items-md-center align-items-end flex-md-row">

        <mat-form-field class="w-100 standalone-field me-2">
          <span
            matPrefix
            matTooltip="Epochs or full cycles through the training set"
            class="d-flex flex-nowrap align-items-center justify-content-between me-2">
            <mat-icon>autorenew</mat-icon>
            <span class="text-muted">|</span>
          </span>
          <input
            matInput
            placeholder="Epochs"
            [disabled]="count === 0"
            [(ngModel)]="epochs"
            type="number"
            min="1"
            max="10"
            step="1"
            name="epochs"
            autocomplete="off">
        </mat-form-field>

        <mat-form-field class="w-100 standalone-field">
          <span
            matPrefix
            matTooltip="Batch size or training examples used during a forward and backward pass"
            class="d-flex flex-nowrap align-items-center justify-content-between me-2">
            <mat-icon>swap_horiz</mat-icon>
            <span class="text-muted">|</span>
          </span>
          <input
            matInput
            placeholder="Batch size"
            [disabled]="count === 0"
            [(ngModel)]="batch_size"
            type="number"
            min="1"
            max="256"
            step="1"
            name="batch_size"
            autocomplete="off">
        </mat-form-field>
    
      </div>

    </div>

    <div class="row">

      <div class="col-12 d-flex justify-content-md-between align-items-md-center align-items-end flex-md-row">

        <mat-form-field class="w-100 standalone-field me-2">
          <span
            matPrefix
            matTooltip="Learning rate multiplier"
            class="d-flex flex-nowrap align-items-center justify-content-between me-2">
            <mat-icon>timeline</mat-icon>
            <span class="text-muted">|</span>
          </span>
          <input
            matInput
            placeholder="Learning rate multiplier"
            [disabled]="count === 0"
            [(ngModel)]="learning_rate_multiplier"
            type="number"
            min="0"
            max="1"
            step="0.01"
            name="learning_rate_multiplier"
            autocomplete="off">
        </mat-form-field>

        <mat-form-field class="w-100 standalone-field">
          <span
            matPrefix
            matTooltip="Prompt loss weight"
            class="d-flex flex-nowrap align-items-center justify-content-between me-2">
            <mat-icon>trending_down</mat-icon>
            <span class="text-muted">|</span>
          </span>
          <input
            matInput
            placeholder="Prompt loss weight"
            [disabled]="count === 0"
            [(ngModel)]="prompt_loss_weight"
            type="number"
            min="0"
            max="1"
            step="0.01"
            name="prompt_loss_weight"
            autocomplete="off">
        </mat-form-field>

      </div>

    </div>

  </div>

  <div mat-dialog-actions [align]="'end'">

    <button
      mat-button
      mat-dialog-close>
      Cancel
    </button>

    <button
      mat-flat-button
      [disabled]="count === 0"
      type="submit">
      Start
    </button>

  </div>

</form>
